package org.zlpt.entity.co;

import lombok.Data;
import org.hyperledger.fabric.contract.annotation.DataType;
import org.hyperledger.fabric.contract.annotation.Property;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
import org.zlpt.entity.bo.ContractSignPage;
import org.zlpt.entity.enums.ContractStatus;

/**
 * @author sy
 * @since 2023/5/13
 */
@Data
@DataType
public final class ContractCO implements Serializable {

    public static final String keyPrefiex = "bms_contract:";
    // 合同id
    @Property
    private Long contractId;

    // 合同编号
    @Property
    private String contractNumber;

    // 合同模板id
    @Property
    private Long contractTemplateId;

    // 合同模板id
    @Property
    private ContractTemplateCO contractTemplate;

    // 订单id
    @Property
    private Long orderId;

    // 项目id
    @Property
    private Long projectId;

    // 合约的条款
    @Property
    private List<ContractEntryCO> contractEntries;

    // 合同文件url
    @Property
    private String contractUrl;

    // 出租方id
    @Property
    private Long lessorId;

    // 出租方是否签名
    @Property
    private Boolean lessorSigned;

    // 出租方签名时间
    @Property
    private LocalDateTime lessorSignTime;

    // 承租方id
    @Property
    private Long lesseeId;

    // 承租方是否签名
    @Property
    private Boolean lesseeSigned;

    // 承租方签名时间
    @Property
    private LocalDateTime lesseeSignTime;

    // 生效时间
    @Property
    private LocalDateTime activateTime;

    // 签名页
    @Property
    private ContractSignPage signPage;

    // 合同状态
    @Property
    private ContractStatus contractStatus;

    // 上链交易id
    @Property
    private String txid;

    public String formKey() {
        return keyPrefiex + contractId;
    }
    public static String formKey(Long userId) {
        return keyPrefiex + userId;
    }

}
